# http://www.gnu.org/software/automake/manual/automake.html#Clean
BUILT_SOURCES = madwimax_version.h
CLEANFILES = madwimax_version.h

# magic to include SVN revision number in MadWimax version string

madwimax_version.h: FORCE
	@SVNREV=`LANG=C svnversion -n $(top_srcdir) 2>/dev/null` \
	GITREV=`cd $(top_srcdir); LANG=C git log -1 --pretty=format:%h 2>/dev/null`; \
	if [ ! \( -z "$$SVNREV" -o "$$SVNREV" = "exported" \) ]; then \
		MADWIMAX_VERSION="$(PACKAGE_VERSION)-svn-r$$SVNREV"; \
	elif [ "$$GITREV" ]; then \
		MADWIMAX_VERSION="$(PACKAGE_VERSION)-git-$$GITREV"; \
	else \
		MADWIMAX_VERSION="$(PACKAGE_VERSION)"; \
	fi ; \
	echo '/* Autogenerated file. Do not change. */'    > _madwimax_version.h ; \
	echo '/* This file was generated by "make". */'   >> _madwimax_version.h ; \
	echo "#define MADWIMAX_VERSION_MACRO \"$$MADWIMAX_VERSION\"" >> _madwimax_version.h ; \
	echo "MADWIMAX_VERSION: \"$$MADWIMAX_VERSION\""
	-test -f madwimax_version.h || cp _madwimax_version.h madwimax_version.h
	-cmp -s _madwimax_version.h madwimax_version.h || cp _madwimax_version.h madwimax_version.h
	-rm -f _madwimax_version.h

FORCE:
